class Solution {
public:
	int rob(vector<int>& nums) {
		int len = nums.size();
		if (len == 0) return 0;

		vector<int> dp(len,0);
		dp[len - 1] = nums[len - 1];
        if(len>1)
		    dp[len - 2] = nums[len - 2];
		for (int i = len-3;i > -1;i--)
		{
			dp[i] = *max_element(dp.begin()+i+2,dp.end())+nums[i];
		}

		return *max_element(dp.begin(),dp.end());
	}
};